<?php

/**
 * 项目：红河移动工程现场管理系统
 *
 * 公司：红河移动分公司
 *
 * @author 李朝应
 *
 * E-mail:lichaoying.hh@163.com
 *
 */
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Req_model extends CI_Model {

    function __construct() {
        parent::__construct();
    }
     function insert_save_1_1_1($fiid,$brid,$uid,$username,$tel,$email,$batch,$prname) {
       $data = array(
               'fiid' => $fiid ,     
               'brid' =>$brid ,
               'uid'=>$uid,
               'name'=>$username,
               'batch'=>$batch,
               'tel'=> $tel,
               'email'=>$email,
               'prname'=>$prname,
               'isEnd1'=>false,
               'isEnd2'=>false,
            );  
          $this->db->set('createTime','NOW()',false);   
          $this->db->set('lastUpdateTime','NOW()',false); 
          $this->db->insert('s_req', $data);
         return $this->db->insert_id();  //返回数据插入时的ID
    } 
    function update_save_1_1_1($rid,$fiid,$brid,$username,$tel,$email,$batch,$prname){
   $data = array(
               'fiid' => $fiid ,     
               'brid' =>$brid ,
               'name'=>$username,
               'batch'=>$batch,
               'tel'=> $tel,
               'email'=>$email,
               'prname'=>$prname,
               'isEnd1'=>false,
               'isEnd2'=>false,
            );  
          $this->db->set('lastUpdateTime','NOW()',false);  
          $this->db->where("rid", $rid);
          $this->db->update('s_req', $data);
          return $this->db->affected_rows() ;   //执行写入操作（insert,update等）的查询后，显示被影响的行数
    }
  function update_save_1_1_2($rid,$pcode,$ptype,$sgdw,$rcAddr,$xcsg,$xcjl,$xcsgd,$branchPm,$rcPlanDate,$tcPlanDate,$mainProjectContent,$mainProjectReady,$sjdw,$jldw){
      $data = array(
               'pcode' => $pcode ,     
               'ptype' =>$ptype ,
               'sgdw'=>$sgdw,
               'jldw'=> $jldw,
               'sjdw'=>$sjdw,
               'rcPlanDate'=>$rcPlanDate,
               'tcPlanDate'=>$tcPlanDate,
               'rcAddr'=>$rcAddr,
                'xcsg'=>$xcsg,
               'xcjl'=> $xcjl,
               'xcsgd'=>$xcsgd,
               'branchPm'=>$branchPm,
               'mainProjectContent'=>$mainProjectContent,
               'mainProjectReady'=>$mainProjectReady,
            );
      $this->db->set('lastUpdateTime','NOW()',false);  
      $this->db->where("rid", $rid);
      $this->db->update('s_req', $data);
      return $this->db->affected_rows() ;   //执行写入操作（insert,update等）的查询后，显示被影响的行数
  }
 function getRiWordNumByBrid($brid){
     return $this->db->where('brid',$brid)->where('riWord !=',"")->get('s_req')->num_rows();
 }
 function isNullRiWord($rid){
    $ri=$this->db->where('rid',$rid)->get('s_req')->row()->riWord; 
    if($ri==""):
       return true;
    else:
       return false; 
    endif;
 }
 function updateRiWord($rid,$RiWord){
      $data=array( 'riWord'=>$RiWord );
      $this->db->set('lastUpdateTime','NOW()',false);  
      $this->db->where("rid", $rid);
      $this->db->update('s_req', $data);
      return $this->db->affected_rows() ;   //执行写入操作（insert,update等）的查询后，显示被影响的行数  
 }
 function getRiReqByRid($rid){
     return $this->db->where('rid',$rid)->get('s_req')->row();
 }
}